load("//:build_variables.bzl", "COPTS")
load("//tools/lint:linters.bzl", "clang_tidy_test")

package(
    default_visibility = ["//:android_cuttlefish"],
)

cc_binary(
    name = "metrics",
    srcs = [
        "events.cc",
        "events.h",
        "host_receiver.cc",
        "host_receiver.h",
        "metrics.cc",
    ],
    copts = COPTS,
    deps = [
        ":libmetrics_utils",
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:flag_parser",
        "//cuttlefish/common/libs/utils:tee_logging",
        "//cuttlefish/host/commands/metrics/proto:metrics_protos",
        "//cuttlefish/host/libs/config:cuttlefish_config",
        "//cuttlefish/host/libs/metrics",
        "//cuttlefish/host/libs/metrics:metrics_headers",
        "//cuttlefish/host/libs/msg_queue",
        "//libbase",
        "@curl",
        "@fruit",
        "@gflags",
        "@jsoncpp",
        "@protobuf",
    ],
)

clang_tidy_test(
    name = "metrics_clang_tidy",
    srcs = [":metrics"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "libmetrics_utils",
    srcs = [
        "utils.cc",
    ],
    hdrs = [
        "utils.h",
    ],
    copts = COPTS,
    deps = [
        "//cuttlefish/common/libs/utils:tee_logging",
        "//cuttlefish/host/commands/metrics/proto:metrics_protos",
        "//cuttlefish/host/libs/metrics:metrics_headers",
        "//libbase",
        "@curl",
        "@gflags",
    ]
)

clang_tidy_test(
    name = "libmetrics_utils_clang_tidy",
    srcs = [":libmetrics_utils"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_test(
    name = "metrics_test",
    srcs = [
        "unittest/utils_tests.cpp",
    ],
    copts = COPTS,
    deps = [
        ":libmetrics_utils",
        "@googletest//:gtest",
        "@googletest//:gtest_main",
    ],
)
